<?php
require_once 'models/models_chungloai.php';
$mod = $_GET['mod'];
$obcl = new models_chungloai();
switch ($mod)
{
	case 'chungloai':{
		$data['list'] = $obcl->listchungloai();
		require 'views/admin/chungloai/index.php';
		break;
	}
	case 'addchungloaihang':{
		if($_POST)
		{
			$obcl->_addchungloai($_POST['tencl']);	
			echo '<script> window.location.href="admin.php?mod=chungloai"</script>';
		}
		require 'views/admin/chungloai/add.php';
		break;
	}
	case 'delchungloaihang':{
		$obcl->del_chungloai($_GET['ma']);
		echo '<script> window.location.href="admin.php?mod=chungloai"</script>';
		break;
	}
	case 'updatechungloaihang':{
		if($_POST){
				$obcl->updateChungLoai($_POST['tencl'], $_GET['ma']);
				echo '<script>window.location.href="admin.php?mod=chungloai"</script>';
		}
		$data = $obcl->getChungLoai($_GET['ma']);
		require 'views/admin/chungloai/edit.php';
		break;
	}
	default: echo 'Khong tim thay yeu cau !';
		break ;
}
?>